<script language="javascript">
// function: UnAssignment
function assignList()
{
// loop through first listbox and append to second listbox
$('#firstList :selected').each(function(i, selected){
// append to second list box
$('#secondList').append('<option value="'+selected.value+'">'+ selected.text+'</option>');
// remove from first list box
$("#firstList option[value='"+ selected.value +"']").remove();
});
}
// function: UnAssignment
function unassignList()
{
// loop through second listbox and append to first listbox
$('#secondList :selected').each(function(i, selected){
// append to first list box
$('#firstList').append('<option value="'+selected.value+'">'+ selected.text+'</option>');
// remove from second list box
$("#secondList option[value='"+ selected.value +"']").remove();
});
}
function loadGroupsIntoForm() {
   // Obtener los elementos de la lista...
   var sel="";
   var id=document.getElementById('firstList');
   for(var i=0; i< id.options.length; i++) {
      sel+= id.options[i].value + '\\';
  }
  sel+="___none___";
  // Meter en el formulario para enviar...
  document.getElementById('grp_members').value=sel;
}
</script>
<div id="modalBackground11" name="modalBackground11"></div>
<form method="post"  id="ajaxpopform11" class='ajaxpopform11' style="display:none" action="AJAX.groupUpdateMembers.php"  >  
<div class='ajaxpopformwrapper11'>
  <div class="ajaxpopforminner11">
    <h2>Pertenencia a grupos</h2>
    <p>Por favor, seleccione los usuarios que pertenecer&aacute;n a este grupo</p>
    <input type="hidden" name="grp_login" id="grp_login" value="" />
    <input type="hidden" name="grp_members" id="grp_members" value="" />
    <table>
      <tr>
       <td align="center">
           Usuarios miembros<br/>
           <select id="firstList" multiple="multiple" style="height:150px;width: 150px;" ></select>
       </td>
       <td align="center" width="100px" >
           <input style="width:25px" type="button" id="to2" name="to2" title='assign' value=">" onclick="assignList()" /><br/><br/>
           <input style="width:25px" type="button" id="to1" name="to1" title='unassign' value="<" onclick="unassignList()">
       </td>
       <td align="center">
           Usuarios disponibles<br/>
           <select id="secondList" multiple="multiple" style="height:150px;width: 150px;" ></select>
       </td>
      </tr>
      <tr>
       <td colspan="3" width="100%" ><div id="errormsg11" class="errormsg11"/></td>
      </tr>
    </table>
  </div>

  <div class="buttons">
     <div class="submit-button11"><a  class="button form-submit-button"><span class="inner">Actualizar</span></a></div>
     <a class="button cancel"><span class="inner">Cancelar</span></a>
  </div>
</div>    

    <!-- Toggle and show this on success -->
    <div style="display:none" id="ajaxpopform-success11">
      <div class="inner">
        <h2>Cuenta de grupo actualizada</h2>
        <h4>En unos segundos los cambios ser&aacute;n efectivos</h4>
      </div>
      <div class="buttons">
        <a class="button cancel"><span class="inner">Cerrar</span></a>
      </div>
    </div>
</form>
